<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" session="false" %>
<%@ page import="com.eos.data.datacontext.DataContextManager"%>	
<%
	String basePath =request.getScheme()+"://"+ request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";
	String talentName = request.getParameter("talentName");
 %>	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- 
  - Author(s): Administrator
  - Date: 2018-03-22 20:42:07
  - Description:
-->
<head>
<title>入职HR人员选择控件</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
     <script src="<%= request.getContextPath() %>/css/js/jquery.min.js" type="text/javascript"></script>
    <script src="<%= request.getContextPath() %>/css/bootstrap-3.3.7-dist/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="<%= request.getContextPath() %>/css/bootstrap-3.3.7-dist/js/bootstrapValidator.min.js" type="text/javascript"></script>
    <script src="<%= request.getContextPath() %>/coframe/tools/layui/layui.js" type="text/javascript"></script>
    <script src="<%= request.getContextPath() %>/commonRecruit/recruit.js" type="text/javascript"></script>
    
  <link href="<%= request.getContextPath() %>/css/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="<%= request.getContextPath() %>/css/bootstrap-3.3.7-dist/css/bootstrapValidator.min.css" rel="stylesheet">
    <link href="<%= request.getContextPath() %>/css/layui/css/layui.css" rel="stylesheet">
    <link href="<%= request.getContextPath() %>/css/css/bootstarp.css" rel="stylesheet">
    <style type="text/css">
    	.form-control{
    		  width: 13%;
    		  float: left;
    		  height: 28px;
    	}
    	.span1{
    		  float: left;
    		  padding-top:8px;
    	}
    	.span-name{
    		/* padding-left: 20%; */
    	}
    	.span-oddnum{
    		margin-left: 13px;
    	}
    	
    	.layui-table-cell{
    		text-align: center;
    	}
    	#content-data{
    		height:364px; 
    		width:420px;
    		overflow-x:auto; 
    		float: left;
    		border-top: 1px solid #e6e6e6;
    		border-bottom: 1px solid #e6e6e6; 
    		margin-top: 39px;
    	} 
    	.layui-tree li{
    		overflow: inherit;
    	} 
    	 
    	.btn-query{
    		width: 70px;
    		height: 29px;
    		padding-top: 3px;
    		margin-left: 6px;
    	}
    	.btn-ok{
    		width: 70px;
    		height: 29px;
    		padding-top: 3px;  
    		margin-left: 50%;   
    	}
    	.btn-cancel{
    		width: 70px;
    		height: 29px;
    		padding-top: 3px;  
    		margin-left: 6px;
    	}
		.layui-table-cell .layui-form-checkbox[lay-skin="primary"] {
		
		    top: 0px;
		    vertical-align: middle;
		
		}
		.layui-form-checkbox[lay-skin="primary"]:hover i {
		    border-color: #f0ad4e;
		    color: #fff;
		}
		.layui-form-checked[lay-skin="primary"] i {
		    border-color: #f0ad4e;
		    background-color: #f0ad4e;
		    color: #fff;
		}
		
		
		  .laytable-cell-radio.layui-table-cell{ padding:0 5px 0 15px; }
  .laytable-cell-radio span{ display: none; }
  .laytable-cell-radio .layui-form-radio{ padding-right: 0; margin:0; }  
		
    </style>
</head>
<body>
	<div id="content-data"> 
		<ul id="demo1" class="demo1"></ul>
	</div>

<div>
	<span class="span1 span-name">姓名：</span><input type="text" id="empName" class="form-control" >
	  <span class="span1 span-oddnum"> 工号：</span><input type="text" id="empId" class="form-control">
	
	<button type="button"  onclick="selectName()" class="btn btn-primary btn-query"   data-complete-text="Loading finished">查询</button>
	<table id="demo" lay-filter="test" class="layui-hide">
	
	</table>
					
</div>
<div>
	<!-- <button type="button" onclick="" class="btn btn-primary btn-ok" data-type="SelectedEmp"  data-complete-text="Loading finished">确认</button>
	<button type="button" onclick="" class="btn btn-primary btn-cancel"  data-complete-text="Loading finished">取消</button> -->
</div>
	
	<script type="text/javascript">
	//获取域名参数
	var server_context='<%= basePath%>';
   var list="[]";	
   var  jsonList = JSON.parse(list);
  layui.use('table', function(){
  var table = layui.table;
  
});
   	
    $(function() {
    var mname='<%=talentName %>';
    if(mname!='null'){
    	$("#empName").val(mname);
    	showName("",mname,""); //默认加载集团人员
    }else{
    	showName("","","00000001"); //默认加载集团人员
    }
    
     $.ajax({
           url: 'org.gocom.components.coframe.tools.PlugIn.sectionBuild.biz.ext',
				type:'POST',
				cache: false,
				success:function(data){
				
					layui.use(['tree', 'layer'], function(){
					  var layer = layui.layer
					  ,$ = layui.jquery; 
					  layui.tree({
					    elem: '#demo1' //指定元素
					    ,skin: 'red'
					    ,target: '_blank' //是否新选项卡打开（比如节点返回href才有效）
					    ,click: function(item){ //点击节点回调
					      /* layer.msg('当前节名称：'+ item.name + '<br>全部参数：'+ JSON.stringify(item)); */
					      showName("","",item.id); 
					    }
					    ,nodes:data.orgorganizantion
					  });
		  });
				
				}
			});
	
		
    });
    
    var tables;
    function showName(eid,name,id){
    	$.ajax({
  			url:"org.gocom.components.coframe.tools.PlugIn.queryEmployee.biz.ext",
  			type:"POST",
  			datatype: "json",
  			data:{
  				enpId:eid,
  				empName:name,
  				orgId:id
  			},
  			success:function(data){
  				console.log(data);
  				scheduleList='[]';
  				var  jsonArray = JSON.parse(scheduleList);
  				$(data.ViewEmployee).each(function(index,obj){
  					var arr = {"username": obj.empname, "order":obj.empid,"job":obj.posiname,"email":obj.email,"beginData":obj.sfybegindate,"phone":obj.phone};
					jsonArray.push(arr);
  				});
  				layui.use('table', function(){
		  
		  	var table = layui.table;
		  	table.render({
		    elem: '#demo'
		    ,height: 364
		    ,data: jsonArray
		    ,cols: [[
		       {radio: true, LAY_CHECKED: false}
		      ,{field:'username', width:130, title: '姓名'}
		      ,{field:'order', width:110, title: '工号', sort: true}
		      ,{field:'job', width:175, title: '职位', sort: true} 
		      ,{field:'beginData', width:136, title: '入职时间', sort: true} 
		      ,{field:'phone', width:175, title: '号码', sort: true} 
		    ]]
		    ,skin: 'row' //表格风格
		    ,page: true
		  });
		    table.on('radio(test)', function(obj){
			    $(jsonList).each(function(i,entry){
				      	jsonList.splice(i,1);
				 }); 
				 jsonList.push(obj.data);
				 
			  });
		  //获取选中行数据
		  //var radioStatus = table.radioStatus('demo'); //test即为基础参数id对应的值
	
		 table.on('checkbox', function(obj){
			  
			  
			  
			  		if(obj.checked==true){
				  	jsonList.push(obj.data);
				  }else{
				  	$(jsonList).each(function(i,entry){
				  		
				      if(entry.order==obj.data.order){
				      	jsonList.splice(i,1);
				      }
				  }); 
				  }
			  
			  
			}); 
		var $ = layui.$, active = {
		    SelectedEmp: function(){ //获取选中数据 
		      var checkStatus = table.checkStatus('demo'),
		    	data = checkStatus.data;
		      	
		      	if(data.length>='2'){
		      		layer.msg('请选择单个人员');
		      		return; 
		      	}else{
		      		
		      		layer.alert(JSON.stringify(data));
		      	}
		    }
			};
			
			
			
			$('.btn-ok').on('click', function(){
			    var type = $(this).data('type');
			    active[type] ? active[type].call(this) : '';
			  });
		});
  				
  			}
  			
  			});
    	 
    }
    
    function selectName(){
    	showName($("#empId").val(),$("#empName").val(),"");
    }
    function getData(){
        return jsonList;
    }
    
    
    /* $(document).on("click",".layui-table-body table.layui-table tbody tr",function(){
		var obj = event ? event.target : event.srcElement;
		var tag = obj.tagName;
		var checkbox = $(this).find("td div.laytable-cell-checkbox div.layui-form-checkbox I");
		if(checkbox.length!=0){
			if(tag == 'DIV') {
				checkbox.click();
	        }
		}
		
	});
	
	$(document).on("click","td div.laytable-cell-checkbox div.layui-form-checkbox",function(e){
		e.stopPropagation();
	});	 */
    </script>
    
  <script src="<%= request.getContextPath() %>/commonRecruit/menuVerify.js" type="text/javascript"></script>
</body>
</html>